package com.zhentao.controller;

import com.zhentao.pojo.Category;
import com.zhentao.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 分类表 前端控制器
 * </p>
 *
 * @author gyz
 * @since 2025-09-27
 */
@RestController
@RequestMapping("/category")
@CrossOrigin(origins = "*")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;
    //课程分类
    @RequestMapping("getCategory")
    public Object getCategory(){
        List<Category> list = categoryService.list();
        List<Category> list1 = new ArrayList<>();
        for (Category category : list) {
            if(category.getType().equals("content")){
                list1.add(category);
            }
        }
        return  list1;
    }

}

